package com.lz.football.module.activity.festival
{
	import com.common.utils.Reflection;
	import com.liangzhong.model.activity.vip.VipVo;
	import com.liangzhong.model.goods.vo.GoodsVo;
	import com.lz.football.module.base.IComponent;
	
	import common.BaseView.DisplayMouseEventManager;
	import common.BaseView.GoodItem;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	public class FestivalItem extends Sprite implements IComponent
	{
		private var _skin:MovieClip;
		/**
		 *物品容器  
		 */
		private var contain:MovieClip;
		
		/**
		 *vip等级 
		 */
		private var vipLv:MovieClip;
		public function FestivalItem()
		{
			super();
		}
		
		public function initUI(view:Object=null):void
		{
			_skin = Reflection.createInstance("com.lz.modul.festival.item");
			this.addChild(_skin);
			contain = _skin.contain;
			vipLv = _skin.vipLv;
			vipLv.gotoAndStop(1);
		}
		/**
		 *设置数据 
		 * @param $vo
		 * 
		 */
		public function setDate($vo:VipVo):void
		{
			if($vo.lv <= 0)
			{
				vipLv.gotoAndStop( 13);
			}else
			{
				vipLv.gotoAndStop($vo.lv);
			}
			var arr:Array = $vo.daily;
			var len:int = arr.length;
			var item:GoodItem;
			//			itemContain.x = 
			for(var i:int = 0;i < len;i++)
			{
				item = new GoodItem();
				
				if(arr[i].goods != null)
				{
					item.initUI();
					item.data = arr[i].goods;
//					item.showNameAndNum((item.data as GoodsVo).name +"*" +arr[i].num );
				}else
				{
					var mc:MovieClip= Reflection.createInstance("com.lz.commonUI.point");
					item.addChild(mc);
					mc.x = 0;
					DisplayMouseEventManager.instance.addTipsDisplay(item,"点券* " +arr[i].num);
//					item.showNameAndNum("点券* " +arr[i].num);
				}
				item.showNum(arr[i].num);
				item.x = 60 * contain.numChildren;
				contain.addChild(item);
			}
		}
		public function addEvtListener():void
		{
		}
		
		public function removeEvtListener():void
		{
		}
		
		public function destroyView():void
		{
			var item :GoodItem;
			while(contain.numChildren)
			{
				item = contain.removeChildAt(0) as GoodItem;
				item.destroyView();
				DisplayMouseEventManager.instance.removeTipsDisplay(item);
				item = null;
			}
		}
	}
}